//https://leetcode.cn/problems/bao-han-minhan-shu-de-zhan-lcof/
class MinStack {
public:
    /** initialize your data structure here. */
    MinStack() {
    }

    void push(int x) {
        if (_min.empty())
        {
            _min.push(x);
        }
        else
        {
            if (x < _min.top())
            {
                _min.push(x);
            }
            else
            {
                _min.push(_min.top());
            }
        }
        _st.push(x);
    }

    void pop() {
        _min.pop();
        _st.pop();
    }

    int top() {
        return _st.top();
    }

    int min() {
        return _min.top();
    }

private:
    stack<int> _min;
    stack<int> _st;
};